{template $cfg['floder'].'/header'}
<script src="{MODULE_URL}template/resources/js/swiper.min.js"></script>
<link href="{MODULE_URL}template/resources/js/swiper.min.css" rel="stylesheet">
<style>
html,body{height:100%; overflow:hidden;}
body{ padding:10px 15px}
.mainbody{margin-top:68px; position:relative}
.page_left{float:left;width:310px;max-width:310px;}
a:link,a:visited,a:hover,a:active{ text-decoration:none;}
.page_right{float:right;}
.left_top{ background:#FFF; position:relative; padding:10px 5px;display:-webkit-box;display:box; margin-bottom:5px}
.left_top span:first-child{ display:block;-webkit-box-flex:1;box-flex:1;max-width:38px;width:38px;text-align:center;line-height:30px;color:#999;font-size:20px}
.left_top span:last-child{display:block;text-align:right; line-height:30px;color:#999;font-size:20px;}
.left_top span:nth-child(2){display:block;-webkit-box-flex:11;box-flex:11;}
.left_top input{ border:none; background:none; margin:0;padding:0; font-size:14px; height:30px;}
.left_menu{ background:#FFF;}
.menu_bar{ padding:10px; border-bottom:1px #DDD solid;line-height:30px;}
.temp_1{display:-webkit-box;display:box;}
.temp_1 .til{-webkit-box-flex:6;box-flex:6;}
.temp_1 .num{-webkit-box-flex:4;box-flex:4;max-width:90px;width:90px;text-align:center}
.temp_1 .price{-webkit-box-flex:2;box-flex:2; text-align:right;max-width:80px;width:80px;}
.temp_1 span{ color:#F66; font-weight:bold;}
.menu_bar b{color:#F66; font-weight:normal}
#Txt_search{ width:100%;}
.listmenu{ overflow:hidden; border-bottom:1px solid #DDD;}
.listmenu li{ padding:10px;border-bottom:1px solid #DDD; cursor:pointer;display:-webkit-box;display:-webkit-flex;display:flex;-webkit-box-align:center;-webkit-align-items:center;align-items:center; height:40px;}
.listmenu li .til{ width:120px;}
.listmenu li .numinput{max-width:90px;width:90px;text-align:center;vertical-align:middle}
.listmenu li .priceinput{text-align:right;max-width:80px;width:80px;color:#FF5722;vertical-align:middle}
.listmenu li .txt_num{ display:inline-block; width:30px;}
.listmenu li .btnmenu{ color:#999}
.listmenu li .btnmenu:active{ color:#F66}
.listmenu li .priceinput s{ display:block; text-align:right; color:#666; font-size:60%;}
.listmenu li.isselect{background:#EEE;}
.listmenu li.isselect .btnmenu{color:#FF5722}

.left_menu_btngroup{border-bottom:1px #DDD solid;line-height:24px;}
.left_menu_btngroup a{ display:block; text-align:center; line-height:40px;}
.left_menu_btngroup a:hover{color:#fff; background:#F66}
.left_menu_btngroup a.isselect{color:#fff; background:#F66}
.btnnone{ background:none; border:none; display:block; width:100%; height:100%;}
.menubtnpay{ line-height:60px; height:60px;display:-webkit-box;display:box;}
.menubtnpay .btnprint{-webkit-box-flex:5;box-flex:5; width:120px; max-width:120px; text-align:center; color:#FFF; border-right:1px solid #EEE;}
.menubtnpay .btnpay{-webkit-box-flex:7;box-flex:7;text-align:center;color:#FFF}
.menubtnpay button{ background:#F66;color:#FFF;font-size:16px; border:none; display:block; width:100%;}
.menubtnpay button i{ font-size:24px;}

.page_middle{float:left;width:90px; margin:0 24px}
.page_middle li{ margin:0 0 5px 0; cursor:pointer; text-align:center; padding:13px 0; background:#FFF; font-size:16px;}
.page_middle li.info{ background:#886dd3; color:#FFF;}
.page_middle li.success{ background:#90b82d; color:#FFF;}

.right_topbar{height:50px;line-height:50px;overflow:hidden;position:relative;padding:0 50px;}
.right_topbar_btnleft{position:absolute;left:0;top:0;width:50px;text-align:center;background:#90b82d; z-index:1;color:#FFF;cursor:pointer}
.right_topbar_btnright{position:absolute;right:0;top:0;width:50px;text-align:center;background:#90b82d;z-index:1;color:#FFF;cursor:pointer}

.right_topmenu{margin:0;padding:0;height:50px;width:100%;}
.right_topmenu .swiper-slide{display:-webkit-box;display:-webkit-flex;display:flex;}
.right_topmenu .swiper-slide a{display:block; background:#FFF; text-align:center; height:50px; line-height:50px; margin-right:10px; width:100%}
.right_topmenu .isselect a{background:#F66; color:#FFF;}

.right_goodslist{overflow:hidden; margin-top:10px;}
.right_goodslist .swiper-container{width:100%;height:300px;padding:0;margin:0}
.right_goodslist .swiper-slide {display:-webkit-box;display:-webkit-flex;display:flex;}
ul.goodlist{ width:100%; height:100%;}
ul.goodlist li{width:32.5%; max-width:170px;display:inline-block; margin:0 0 10px 0; text-align:left;}
ul.goodlist li a{display:block;margin-right:10px; background:#FFF; position:relative;}
ul.goodlist li a .img{display:block;height: 100px;overflow: hidden;}
ul.goodlist li a .info{ padding:5px;}
ul.goodlist li a .info h3{ font-size:14px; margin:0; padding:0; text-align:left; line-height:24px; margin-bottom:5px}
ul.goodlist li a .info p{ margin-bottom:5px}
ul.goodlist li a:active{ background:#F66; color:#FFF}
.page_table{position:absolute;z-index:10; right:0; top:0; bottom:0; left:334px;background:#FFF; height:100%;}
.page_table_top{ background:#434540; padding:15px 20px; text-align:center; color:#FFF;}
.page_table_body{ clear:both; padding:10px 15px; background:#FFF}
.page_table_menubar{ position:relative; padding:0 30px; height:40px; line-height:40px;}
.pt_menubar{ height:40px; background:#EEE}
.pt_pagebtn_l{ position:absolute; left:0; top:0; width:30px; height:40px; background:#90b82d;color:#FFF; text-align:center; cursor:pointer}
.pt_pagebtn_r{ position:absolute; right:0; top:0;width:30px;height:40px;background:#90b82d;color:#FFF; text-align:center;cursor:pointer}
.pt_menuitem{text-align: center; font-size: 18px;background: #fff;display: -webkit-box;display: -webkit-flex;display: flex; -webkit-box-pack: center;-webkit-justify-content: center;justify-content: center;-webkit-box-align: center;-webkit-align-items: center; align-items: center;}
.pt_menuitem a{display:block; text-align:center;border-bottom:2px solid #FFF;line-height:38px; width:100%}
.pt_menubar .isselect a{border-bottom:2px solid #F60;}
.pt_status{ padding:20px 0;}

.cirle{display:inline-block; width:14px; height:14px; border-radius:100%; background:#CCC;}
.cirle_red{background:#F66;}
.cirle_success{background:#91ba30;}
.page_table_list{ clear:both; padding:0 10px}
.page_table_list .swiper-container{width:100%;padding:0;margin:0}
.page_table_list .swiper-slide{display:-webkit-box;display:-webkit-flex;display:flex;}
.page_table_list ul{ width:100%;  height:100%}
.page_table_list li{height:150px;min-width:110px;max-width:150px;margin:0 0 10px 0;width:24.5%; display:inline-block }
.page_table_list li a{display:block;height:150px;margin-right:5px;border:1px solid #CCC;padding:5px;}
.page_table_list li a h2{ margin:15px 0; padding:10px; text-align:center; font-size:20px; line-height:20px;}
.page_table_list li a .pt_label span{ display:inline-block; padding:2px 3px; border-radius:4px; color:#FFF; background:#F66; font-size:60%}
.pt_tablelist .status_0 a{ background:#FFF;}
.pt_tablelist .status_1 a{ background:#8fb82c;color:#FFF}
.pt_tablelist .status_2 a{ background:#ff6666;color:#FFF}
.page_table_list li.isselect a{background:#EEE;color:#000}
#txt_tablename{ color:#F00; font-size:16px;}

.extension span{ display:inline-block; padding:2px; font-size:60%; border-radius:4px; background:#F66;color:#FFF;}
.extension .ispack{ background:#F66;}
.extension .ispay{ background:#90b82d;}
.taste{font-size:60%;}
.label{font-size:80%;}
.label-red{ background:#F66; color:#FFF;}
</style>
<section class="mainbody">
  <aside class="page_left">
    <form class="layui-form" id="form_search" onsubmit="return searchgoods();return false;" action="">
    <div class="left_top">
      <span onclick="fun_showinput()"><i class="fa fa-font"></i></span>
      <span><input type="text" name="Txt_search" id="Txt_search" placeholder="条码/助词码（大写）/价格（0~20000)"/></span>
      <span class="btnremove" onclick="$('#Txt_search').val('');$('#Txt_search').focus();"><i class="fa fa-remove-sign"></i></span>
    </div>
    <input type="submit" lay-submit="" id="btnsearch" lay-filter="btnsearch" style="display:none;"/>
    </form>
    
    <form class="layui-form" id="form_menu" action="">
    <input type="hidden" name="orderid" id="orderid" />
    <input type="hidden" name="person" id="person" />
    <div class="left_menu">
    	<div class="menu_bar" onclick="$('.listmenu li').removeClass('isselect');">
        	<div class="row">
            	<div class="col-md-5">牌号：<span id="txt_tablename"></span></div>
                <div class="col-md-7">人数：<b id="txt_person"></b>&nbsp;茶位：<b id="txt_teafee"></b> </div>
            </div>
            <div class="temp_1">
            	<div class="til">品名 <span></span></div>
                <div class="num">数量 <span></span></div>
                <div class="price">金额</div>
            </div>
        </div>
        <div class="pl_menubox swiper-container">
          <ul class="swiper-wrapper listmenu">
           
          </ul>
        </div>
        <div class="left_menu_btngroup" style="padding:5px 10px">
        	<div class="row">
            	<div class="col-md-6 text-center"><input type="radio" name="ispack" lay-filter="ispack" value="0" title="堂食" checked /></div>
                <div class="col-md-6 text-center"><input type="radio" name="ispack" lay-filter="ispack" value="1" title="打包" /></div>
            </div>
        </div>
        <div class="left_menu_btngroup lm_btngroup" style="margin-bottom:10px">
        	<div class="row">
            	<div class="col-md-6 text-center"><a href="javascript:" onclick="fun_munebtn_clear()">清空</a></div>
                <div class="col-md-6 text-center"><a href="javascript:" id="btn_getback" >&nbsp;</a><a href="javascript:" id="btn_submitorder" onclick="fun_munebtn_submitorder()" style="display:none">下单</a></div>
            </div>
        </div>
        <div class="menubtnpay">
        	<div class="btnprint">
            	<button type="button"><i class="fa fa-print"></i></button>
            </div>
            <div class="btnpay"><button type="button" lay-submit="" id="btnpay" lay-filter="btnpay" style="text-align:left; text-indent:15px">收款：<b id="txt_total">0.00</b></button></div>
        </div>
    </div>
    </form>
  </aside>
  <aside class="page_middle">
    <ul>
    	<li class="success" onclick="funmenu_number(0)">口味</li>
        <li class="success" onclick="fun_selectTablePcate(0)">房台</li>
        <li onclick="funSys_keyboard()">快速</li>
        <li onclick="funmenu_number(1)">数量</li>
        {if $user["permission"]>2}
        <li onclick="funmenu_number(2)">折扣</li>
        <li onclick="funmenu_number(3)">改价</li>
        {/if}
        <li onclick="funmenu_number(5)">退菜</li>
        <li onclick="funmenu_number(4)">删除</li>
        <li onclick="funExtend_charge()">充值</li>
        <li onclick="funExtend_member()">会员</li>
        <li onclick="funExtend_history()">交易</li>
        <li onclick="funExtend_gift()">兑换</li>
        {php $btnlist=json_decode($shop['btnlist'],true)}
        {if count($btnlist)}
        {loop $btnlist $index $row}
        <li onclick="funExtend_btn(this)" url="{$row}">{$index}</li>
        {/loop}
        {/if}
    </ul>
  </aside>
  <aside class="page_right">
    <div class="right_topbar">
      <div class="right_topbar_btnleft"><i class="fa fa-menu-left"></i></div>
      <div class="right_topmenu swiper-container">
        <div class="swiper-wrapper">
            {if $ispackage}
            <div class="swiper-slide" gcid="-2"><a href="javascript:" onclick="fun_selectgoodpcate(-2)">套餐</a></div>{/if}
          {if $isfungood}
          <div class="swiper-slide" gcid="-1"><a href="javascript:" onclick="fun_selectgoodpcate(-1)">活动商品</a></div>{/if}
          {if $isNoPcate}<div class="swiper-slide" gcid="0"><a href="javascript:" onclick="fun_selectgoodpcate(0)">未分类</a></div>{/if}
          {loop $goodpcatelist $row}
          <div class="swiper-slide" gcid="{$row['id']}"><a href="javascript:" onclick="fun_selectgoodpcate({$row['id']})">{$row['title']}</a></div>
          {/loop}
        </div>
      </div>
      <div class="right_topbar_btnright"><i class="fa fa-menu-right"></i></div>
    </div>
    <div class="right_goodslist">
    	<div class="swiper-container">
            <div class="swiper-wrapper">
                
            </div>
        </div>
    </div>
  </aside>
  
  <aside class="page_table" style="display:none;">
  	<div class="page_table_top">
    	<div class="pull-left" onclick="$('.page_table').hide()">返回</div>
        房台选择
        <div class="pull-right">&nbsp;</div>
    </div>
    <div class="page_table_body">
    	<div class="page_table_menubar">
        <div class="pt_pagebtn_l"><i class="fa fa-menu-left"></i></div>
        	<div class="swiper-container pt_menubar">
              <div class="swiper-wrapper">
              	  {loop $tablepcatelist $row}
                  <div class="swiper-slide pt_menuitem" tpcate="{$row['id']}"><A href="javascript:" onclick="fun_selectTablePcate({$row['id']})">{$row['title']}</A></div>
                  {/loop}
              </div>
            </div>
        <div class="pt_pagebtn_r"><i class="fa fa-menu-right"></i></div>
        </div>
        <div class="pt_status pull-right">
            <span class="cirle cirle_success" style="background: #01AAED"></span>等菜
          <span class="cirle cirle_success"></span>已开台 <span id="txt_ptstatus_1">0</span>
          <span class="cirle cirle_red"></span>已点菜 <span id="txt_ptstatus_2">0</span>
          <span class="cirle"></span>空闲 <span id="txt_ptstatus_0">0</span>
          <span class="cirle"></span>全部 <span id="txt_ptstatus_all">0</span>
        </div>
        <div class="page_table_list">
        	<div class="swiper-container pt_tablelist">
              <div class="swiper-wrapper">  
              	<div class="swiper-slide">
                	<ul>
                    	
                    </ul>
                </div>
              </div>
            </div>
        </div>
    </div>
  </aside>
</section>
<style>
.modal_counter{background:#EEE;padding:15px;}
.moad_inputbox{ margin-bottom:15px; position:relative;}
.moad_inputbox input{ border:none;box-shadow:0 0 3px #ddd; border-radius:4px; text-align:right;font-family: 微软雅黑;font-size: 25px;font-weight: bold;color: rgb(102, 102, 102); width:100%; padding:5px 52px 5px 0}
.moad_inputbox span{ position:absolute; right:15px; top:10px; line-height:25px;font-size:25px;color:#CCC}
.modal_counter .modal_body{ padding:0; overflow:hidden}
.modal_counter .modal_body a{ display:block; line-height:55px;box-shadow:0 0 4px #CCC; border-radius:4px; background:#FFF;font-size:25px; text-align:center;}
.bl{ display:inline-block; width:190px}
.bl li{ display:inline-block;width:55px;margin-right:5px;margin-bottom:8px}
.br{ float:right}
.br li{ width:80px;}
.modal_btn_big{height:110px; width:110px; text-align:center; border:1px solid #CCC; border-radius:4px; margin:5px;font-size:24px; background:#FFF}
.modal_btn_big:active,.modal_btn_big:hover{ background:#F66; color:#FFF; }
.modal_tastebox{ text-align:center; padding:10px;}
.modal_tastebox span{ border:1px solid #CCC; display:inline-block; padding:5px; min-width:60px; margin:5px; text-align:center; border-radius:4px; cursor:pointer}
.modal_tastebox span.isselect{ border-color:#90b82d; background:#90b82d; color:#FFF;}
.modal_customgoodbox{ text-align:center; padding:10px;}
.modal_customgoodbox span{ border:1px solid #CCC; display:inline-block; padding:5px; min-width:60px; margin:5px; text-align:center; border-radius:4px; cursor:pointer}
.modal_customgoodbox span.isselect{ border-color:#90b82d; background:#90b82d; color:#FFF;}
</style>
<div class="modal_counter" style="display:none;">
	<div class="moad_inputbox">
    	<input type="text" id="moadConterInput" maxlength="10" />
        <span onclick="$('#moadConterInput').val('')"><i class="fa fa-remove-sign"></i></span>
    </div>
    <div class="modal_body">
    	<div class="bl">
        	<ul>
            	<li><a href="javascript:" onclick="Counter(7,'#moadConterInput')">7</a></li>
                <li><a href="javascript:" onclick="Counter(8,'#moadConterInput')">8</a></li>
                <li><a href="javascript:" onclick="Counter(9,'#moadConterInput')">9</a></li>
                <li><a href="javascript:" onclick="Counter(4,'#moadConterInput')">4</a></li>
                <li><a href="javascript:" onclick="Counter(5,'#moadConterInput')">5</a></li>
                <li><a href="javascript:" onclick="Counter(6,'#moadConterInput')">6</a></li>
                <li><a href="javascript:" onclick="Counter(1,'#moadConterInput')">1</a></li>
                <li><a href="javascript:" onclick="Counter(2,'#moadConterInput')">2</a></li>
                <li><a href="javascript:" onclick="Counter(3,'#moadConterInput')">3</a></li>
                <li style="width:120px"><a href="javascript:" onclick="Counter(0,'#moadConterInput')">0</a></li>
                <li id="modal_doc"><a href="javascript:" onclick="Counter('.','#moadConterInput')">.</a></li>
            </ul>
        </div>
        <div class="br">
        <li style="margin-bottom:8px"><a href="javascript:" id="modal_cantrl"  style=" background:#50a4ec;font-size:20px;color:#FFF">取消</a></li>
        <li><a href="javascript:" id="modal_sure"  style=" background:#1bb987;font-size:24px;color:#FFF; height:180px; padding-top:40px">确<br/>定</a></li>
        </div>
    </div>
</div>
<div class="modal_taste" style="display:none;">
	<div class="modal_tastebox">
    	{php $tasteAry=explode('|',$shop['taste']);}
        {loop $tasteAry $row}
        <span taste="{$row}">{$row}</span>
        {/loop}
    </div>
</div>
<div class="modal_customgood" style="display:none;">
	<div class="modal_customgoodbox">
    	<span taste="无码商品">无码商品</span>
    	{php $tasteAry=explode('|',$shop['customgood']);}
        {loop $tasteAry $row}
        <span taste="{$row}">{$row}</span>
        {/loop}
    </div>
</div>
<div class="modal_selectMovement" index style="display:none;">
	<div id="tablestatus0" style="text-align:center; padding:20px 0" >
    	<button type="button" class="modal_btn_big" onclick="fun_ctrlorder(1)">点菜</button>
        <button type="button" class="modal_btn_big" onclick="fun_ctrlorder(2)">清台</button>
        <button type="button" class="modal_btn_big" onclick="fun_ctrlorder(3)">转台</button>
        <button type="button" class="modal_btn_big" onclick="fun_ctrlorder(8)">人数</button>
        <button type="button" class="modal_btn_big" onclick="layer.closeAll()">关闭</button>
    </div>
    <div id="tablestatus1" style="text-align:center; padding:20px 0;display:none" >
        <button type="button" class="modal_btn_big" index="1" onclick="fun_ctrlorder(4)">加菜</button>
        <button type="button" class="modal_btn_big" index="2" onclick="fun_ctrlorder(3)">转台</button>
        <button type="button" class="modal_btn_big" index="3" onclick="fun_ctrlorder(9)">厨打<samll>新增</samll></button>
        <button type="button" class="modal_btn_big" index="5" onclick="fun_ctrlorder(8)">人数</button>
        <button type="button" class="modal_btn_big" onclick="fun_ctrlorder(7)">收款</button>
        <button type="button" style="display: none;" class="modal_btn_big pauseorder pauseorder1" onclick="fun_ctrlorder(11)">厨房等菜</button>
        <button type="button" style="display: none;" class="modal_btn_big pauseorder pauseorder2" onclick="fun_ctrlorder(12)">上菜厨打</button>
        <button type="button" class="modal_btn_big" onclick="layer.closeAll()">关闭</button>
    </div>
    <div id="tablestatus2" style="text-align:center; padding:20px 0;display:none" >
        <button type="button" class="modal_btn_big" index="6" onclick="fun_ctrlorder(6)">完成</button>
        <button type="button" class="modal_btn_big" onclick="layer.closeAll()">关闭</button>
    </div>
</div>
<div class="modal_AfterSumit" index style="display:none;">
	<div style="text-align:center; padding:20px 0">
    	<span id="isnewgood1">
    	<button type="button" class="modal_btn_big" onclick="fun_ctrlAftersumit(1)">厨打</button>
        </span>
        <span id="isnewgood2" style="display:none">
        <button type="button" class="modal_btn_big" onclick="fun_ctrlAftersumit(1)">厨打<small>全部</small></button>
        <button type="button" class="modal_btn_big" onclick="fun_ctrlAftersumit(3)">厨打<small>新增</small></button>
        </span>
        <button type="button" class="modal_btn_big" onclick="fun_ctrlAftersumit(2)">收款</button>
        <button type="button" class="modal_btn_big pauseorder3" onclick="fun_ctrlAftersumit(4)">厨房等菜</button>
        <button type="button" class="modal_btn_big" onclick="layer.closeAll()">关闭</button>
    </div>
</div>

<div class="modal_inputbox" index style="display:none;">
<form index="" class="layui-form" action="" style="padding:15px">
  <Div class="text-center" id="modal_inputboximg" style="margin:20px 0;"><img src="{MODULE_URL}template/resources/img/scaner.png" /></Div>
  <div class="layui-form-item">
    <input type="text" name="modal_inputbox" id="modal_inputbox" lay-verify="required" placeholder="请输入名称" autocomplete="off" class="layui-input">
  </div>
  <div style="padding:10px; text-align:center" class="help-block"></div>
  <div class="row">
    <div class="col-md-12"><Div class="text-center"> <button class="layui-btn" id="modal_inputboxbtn" type="submit" >提交</button></Div></Div>
  </div>
</form>
</div>
<style>
.modal_selecttable 
.modal_selecttableleft ul li { background:#FFF;padding:10px;text-align:left;font-size:14px; cursor:pointer}
.modal_selecttableleft ul li.isselect{ background:#90b82d;color:#FFF;}
.modal_selecttableright{ height:380px; overflow-y:scroll;}
.modal_selecttableright ul li{width:19.5%;display:inline-block; margin:0 0.2% 5px 0.2%;text-align:left; border:1px solid #EEE; padding:5px;cursor:pointer}
.modal_selecttableright ul li h2{ text-align:center; font-size:14px; font-weight:bold; margin:10px;}
.modal_selecttableright ul li div{ font-size:70%;}
.modal_selecttableright li.status_0 { background:#FFF;}
.modal_selecttableright li.status_1 { background:#8fb82c;color:#FFF}
.modal_selecttableright li.status_2 { background:#ff6666;color:#FFF}
.modal_selecttableright li.isselect {background:#EEE;color:#000}
</style>
<div class="modal_selecttable" style="display:none;">
	<div style="padding:15px;">
    	<div class="row">
          <div class="col-xs-3 modal_selecttableleft">
              <ul>
              	{loop $tablepcatelist $row}
              	<li tpcate="{$row['id']}" onclick="fun_selectTablePcate2({$row['id']})">{$row['title']}</li>
                {/loop}
              </ul>
          </div>
          <div class="col-xs-9">
          	<div class="modal_selecttableright">
                <ul>
                    
                </ul>
            </div>
          </div>
      </div>
    </div>
</div>


<style>
.modal_selectorder {}
.modal_selectorderbox{ padding:20px;}
.modal_selectorderbox ul{width:100%;}
.modal_selectorderbox ul li{display:inline-block;width:120px;height:120px; padding:10px; margin:5px; border:1px solid #CCC; border-radius:4px; cursor:pointer;}
.modal_selectorderbox ul li h3{text-align:center; font-size:16px; padding:10px;}
.modal_selectorderbox ul li p{ margin-bottom:10px; font-size:60%; text-align:center}
.modal_selectorderbox ul li span{ display:inline-block; padding:2px; background:#FF9988; border-radius:4px; color:#FFF;}
.modal_selectorderbox ul li:hover{ background:#90b82d;color:#FFF}
</style>
<div class="modal_selectorder" style="display:none;">
    <div class="modal_selectorderbox">
        <ul>
          
        </ul>
    </div>
</div>

<style>
    .modal_tuigoods{padding:20px;}
</style>
<div class="modal_tuigoods" style="display:none">
    <div class="modal_tuigoodsbox">
        <div class="">
            <form action="" method="post" id="modal_tuigoodsform" class="layui-form">
                <input type="hidden" class="layui-input" id="tgid_mid" value="0" />
                <div class="layui-form-item">
                    <label class="layui-form-label">退菜原因</label>
                    <div class="layui-input-block">
                        <select id="tgid_reason" lay-ignore class="form-control">
                            {if !$shop['refundreason']}
                            <option value="客户原因">客户原因</option>
                            {else}
                            {php $refundreasonAry=explode('|',$shop['refundreason']);}
                            {loop $refundreasonAry $row}
                            <option value="{$row}">{$row}</option>
                            {/loop}
                            {/if}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item mtk_good">
                    <label class="layui-form-label">数量</label>
                    <div class="layui-input-block">
                        <input type="number" min="1" max="3" value="1" class="form-control" id="tgid_num"/>
                    </div>
                </div>
                <div class="layui-form-item mtk_good">
                    <label class="layui-form-label">商品回收</label>
                    <div class="layui-input-block">
                        <input type="radio" name="tgid_getback" value="0" title="不回收" checked/>
                        <input type="radio" name="tgid_getback" value="1" title="回收" />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">通知厨房</label>
                    <div class="layui-input-block">
                        <input type="radio" name="tgid_print" value="1" title="通知厨房" />
                        <input type="radio" name="tgid_print" value="0" title="无" checked/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" id="tgid_remark" />
                    </div>
                </div>
                <div class="text-right">
                    <button type="button" class="layui-btn" lay-submit lay-filter="tgid_btnsubmit">确认退菜</button>
                    <button type="button" class="layui-btn layui-btn-primary tgid_btnclose">关闭</button>
                </div>
            </form>
        </div>
    </div>
</div>
{template 'default/tpl_paybox'}
{template 'default/tpl_charge'}
{template 'default/tpl_member'}
{template 'default/tpl_history'}
{template 'default/tpl_sys'}
{template 'default/tpl_gift'}
{template 'default/tpl_handover'}
{template 'default/tpl_keyboard'}
{template 'socket_wildog'}
<iframe src="" id="print_iframe" name="print_iframe" style="width:1px; height:1px;"></iframe>
<script language="javascript">
var tableSwiper=null;
var tablePcateswiper=null;
var goodsListSwiper=null;
var menuListSwiper=null;
var memuListSwiperSize=0;
$(document).ready(function(e) {
    if($(window).width()>=1660){
        location.href="{php echo $this->createMobileUrl('index')}";
    }
	$(document).bind("keypress",function(event){
		if(event.keyCode == 8){
			  return false;
		}
	});
	$("#print_iframe").attr("src","jetsumprint://order?event=open&shopid={php echo $shopid}&userid={php echo $userid}&weid={$_W['uniacid']}");
    var height=$(window).height()-88;
	var menuheight=height-310;
	$(".pl_menubox").height(menuheight);
	$(".page_right").width($(window).width()-$(".page_left").width()-$(".page_middle").width()-48-30);
	$(".right_goodslist .swiper-container").height(height-65);
	goodsListSwiper = new Swiper('.right_goodslist .swiper-container');
	
	memuListSwiperSize=parseInt(menuheight/60);
	var swiper_goodpcate = new Swiper('.right_topmenu', {
		nextButton: '.right_topbar_btnleft',
		prevButton: '.right_topbar_btnright',
		slidesPerView: 6,
	});
	menuListSwiper = new Swiper('.pl_menubox',{direction:'vertical',slidesPerView:memuListSwiperSize,mousewheelControl:true,});
});
layui.use(['layer', 'laypage', 'element','form'], function(){
	var layer = layui.layer
	,laypage = layui.laypage
	,element = layui.element
	,form = layui.form;
	
	fun_selectgoodpcate(-1);
	
	form.on('radio(ispack)', function(data){
		if(!$(".listmenu li").size()){
			layer.msg("请先点菜",{icon:2,time:2000});
			return;
		}
		if(data.value==1){
			if($(".listmenu .isselect").size()){
				if(!$(".listmenu .isselect").find("span:contains('打包')").size())$(".listmenu .isselect").find(".extension").append("<span class='ispack'>打包</span>");
			}else{
				$(".listmenu li").each(function(index, element) {
					if(!$(this).find("span:contains('打包')").size())$(this).find(".extension").append("<span class='ispack'>打包</span>");
				});
			}
			
		}else if(data.value==0){
			if($(".listmenu .isselect").size()){
				$(".listmenu .isselect span:contains('打包')").remove();
			}else{
				$(".listmenu li span:contains('打包')").remove();
			}
			
		}
		return true;
	});
	form.on('submit(btnpay)', function(data){
		var orderid=$("#orderid").val();
		if(!orderid){
			layer.msg("请选择订单",{icon:2,time:2000});
			return false;
		}
		fun_startPay(orderid);
		return false;
	});
	
	//--------测试用

});
function searchgoods(){
	if(!$("#orderid").val()){
		layer.msg("请先开台",{icon:2,time:2000});
		return false;
	}
	var keyword=$("#Txt_search").val();
	if(!keyword){
		layer.msg("请输入内容",{icon:2,time:2000});
		return false;
	}
	var index2=layer.load(1, {shade: [0.1,'#fff']});
	$.post("{php echo $this->createMobileUrl('index',array('op'=>'searchgood'))}",{keyword:keyword},function(returnstr){
		layer.close(index2);
		console.log(returnstr);
		$("#Txt_search").val('').focus();
		var result=eval("("+returnstr+")");
		if(result.success){
			var goods=result.goods;
			if(!goods){
				layer.msg("无此商品",{icon:2,time:2000});
				return false;
			}
			if(parseInt(goods.id)==0){
				fun_insertCustomGood(goods);
				return;
			}
			var index=$(".listmenu li").size()+1;
			var price=goods.marketprice;
			var mprice=goods.memberprice;
			var title=goods.title;
			var goodsn=goods.goodsn;
			var gid=goods.id;
			menuListSwiper.prependSlide('<li class="swiper-slide" isnew="true" gid="'+gid+'" goodsn="'+goodsn+'" title="'+title+'" price="'+price+'" mprice="'+mprice+'" oprice="'+price+'" onclick="fun_selectmenu(this)"><div class="til">'+title+'<div class="taste"></div><div class="extension"></div></div><div class="numinput"> <span class="txt_num">1</span> </div><div class="priceinput"> <span>￥'+price+'</span> <s></s></div></li>');
			$(".listmenu").css("overflow","visible");
			menuListSwiper.updateSlidesSize();
			menuListSwiper.slideTo(0);
			fun_sumTotal();
		}else{
			layer.msg(result.msg,{icon:2,time:2000});
			return false;
		}
		
	});
	return false;
}
function fun_insertCustomGood(goods){
	layer.open({
		type: 1,
		title:"自定义商品",
		area:'440px',
		skin: 'layui-layer-rim',
		content:$(".modal_customgood").show(),
		btn:['确认','取消'],
		btn1:function(indexs,layero){
			var index=$(".listmenu li").size()+1;
			var price=goods.marketprice;
			var title=$(".modal_customgoodbox .isselect").text();
			menuListSwiper.prependSlide('<li class="swiper-slide" isnew="true" gid="0" goodsn="" title="'+title+'" price="'+price+'" mprice="0" oprice="'+price+'" onclick="fun_selectmenu(this)"><div class="til">'+title+'<div class="taste"></div><div class="extension"></div></div><div class="numinput"> <span class="txt_num">1</span> </div><div class="priceinput"> <span>￥'+price+'</span> <s></s></div></li>');
			$(".listmenu").css("overflow","visible");
			menuListSwiper.updateSlidesSize();
			menuListSwiper.slideTo(0);
			fun_sumTotal();
			layer.close(indexs);
		},
		success: function(layero, index){
			$(".modal_customgoodbox span").bind("click",function(){
				$(this).addClass("isselect").siblings().removeClass("isselect");
			});
			$(".modal_customgoodbox span:eq(0)").click();
		},
		end:function(){
			$(".modal_customgood").hide();
			$(".modal_customgoodbox span").unbind("click");
			$(".modal_customgoodbox span").removeClass("isselect");
		}
	});
}
function fun_showinput(){
	if(!$("#orderid").val()){
		layer.msg("请先开台",{icon:2,time:2000});
		return;
	}
	fun_modal({
		"title":"价格（0~20000)",
		"type":true,
		"success":function(inputval,index){
			layer.close(index);
			$("#Txt_search").val(inputval);
			$("#btnsearch").click();
		}
	});
}
function fun_selectmenu(obj){
	var Index=$(obj).index();
	$(obj).addClass("isselect").siblings().removeClass("isselect");
}
function funmenu_number(type){
	if(!$(".listmenu .isselect").size()){
		layer.msg("请先选择要修改的内容",{icon:2,time:2000});
		return;
	}
	switch(type){
		case 0://口味
            layer.open({
                type: 1,
                title:"选择口味",
                area:'440px',
                skin: 'layui-layer-rim',
                content:$(".modal_taste").show(),
                btn:['确认','取消'],
                btn1:function(index,layero){
                    var temp=[];
                    $(".modal_taste .isselect").each(function(index, element) {
                        temp.push($(this).text());
                    });
                    $(".listmenu .isselect").find(".taste").text(temp.join(','));
                    layer.close(index);

                },
                success: function(layero, index){
                    var gid = $(".listmenu .isselect").attr("gid");
                    var taste = $(".listmenu .isselect").find(".taste").text();
                    var index2=layer.load(1, {shade: [0.1,'#fff']});
                    $.post("{php echo $this->createMobileUrl('index',array('op'=>'getgood'))}",{id:gid},function(returnstr) {
                        layer.close(index2);
                        console.log(returnstr);
                        var result = eval("(" + returnstr + ")");
                        if (result.success) {
                            var good=result.goods;
                            if(good.taste){
                                var tasteStr=good.taste;
                                var tasteAry=tasteStr.split("|");
                                $(".modal_tastebox").empty();
                                var temp="";
                                for(var i in tasteAry){
                                    temp+='<span taste="'+tasteAry[i]+'">'+tasteAry[i]+'</span>';
                                }
                                $(".modal_tastebox").append(temp);
                                $(".modal_tastebox span").bind("click",function(){
                                    if($(this).hasClass("isselect")){
                                        $(this).removeClass("isselect");
                                    }else{
                                        $(this).addClass("isselect");
                                    }
                                });
                                if(taste.length){
                                    var temp=taste.split(",");
                                    for(var i=0;i<temp.length;i++){
                                        $(".modal_tastebox span[taste='"+temp[i]+"']").addClass("isselect");
                                    }
                                }
                            }else{
                                layer.msg("该商品无属性",{icon:2,time:2000},function(){layer.closeAll()});
                            }

                        }else{
                            alert(returnstr);
                        }
                    });
                },
                end:function(){
                    $(".modal_taste").hide();
                    $(".modal_taste span").unbind("click");
                    $(".modal_taste span").removeClass("isselect");
                }
            });
		break;
		case 1://数量
            fun_modal({
                "title":"修改数量",
                "type":false,
                "success":function(inputval,index){
                    layer.close(index);
                    $(".listmenu .isselect .txt_num").text(inputval);
                    var num=parseInt(inputval);
                    var gid=parseInt($(".listmenu .isselect").attr("gid"));
                    var mid=parseInt($(".listmenu .isselect").attr("mid"));
                    var price=str2num(($(".listmenu .isselect").attr("price")));
                    var total=fee2num(num*price);
                    $(".listmenu .isselect .priceinput span").text("￥"+total);
                    fun_sumTotal();
                }
            });
		break;
		case 2://折扣
			var price=parseFloat($(".listmenu .isselect").attr("price"));
			var oprice=parseFloat($(".listmenu .isselect").attr("oprice"));
			var discount=parseInt(price/oprice*100);
			fun_modal({
				"title":"修改折扣",
				"type":false,
				"tips":"当前折扣"+discount,
				"success":function(inputval,index){
					layer.close(index);
					var num=parseInt($(".listmenu .isselect .txt_num").text());
					var newpirce=(parseInt(inputval)*0.01*oprice);
					var total=(num*newpirce).toFixed(2);
					$(".listmenu .isselect .priceinput span").text("￥"+total);
					$(".listmenu .isselect").attr("price",newpirce.toFixed(2));
					var total2=(num*oprice).toFixed(2);
					$(".listmenu .isselect .priceinput s").text("￥"+total2);
					fun_sumTotal();
				}
			});
		break;
		case 3://改价
			var price=parseFloat($(".listmenu .isselect").attr("price"));
			var oprice=parseFloat($(".listmenu .isselect").attr("oprice"));
			fun_modal({
				"title":"修改单价",
				"type":true,
				"tips":"当前单价￥"+price,
				"success":function(inputval,index){
					layer.close(index);
					var num=parseInt($(".listmenu .isselect .txt_num").text());
					var newpirce=parseFloat(inputval);
					var total=(num*newpirce).toFixed(2);
					$(".listmenu .isselect").attr("price",newpirce.toFixed(2));
					var total2=(num*oprice).toFixed(2);
					$(".listmenu .isselect .priceinput span").text("￥"+total);
					$(".listmenu .isselect .priceinput s").text("￥"+total2);
					fun_sumTotal();
				}
			});
		break;
		case 4://删除
            if(parseInt($(".listmenu .isselect").attr("isprint"))){
                layer.confirm('该商品已厨打，确认删除？', {
                    btn: ['删除','取消']
                }, function(indexs){
                    layer.close(indexs);
                    var index=$(".listmenu .isselect").index();
                    menuListSwiper.removeSlide(index);
                    menuListSwiper.update();
                    fun_sumTotal();
                });
            }else{
                var index=$(".listmenu .isselect").index();
                menuListSwiper.removeSlide(index);
                menuListSwiper.update();
                fun_sumTotal();
            }
		break;
        case 5://退菜
            var mid=$(".listmenu .isselect").attr("mid");
            if(!mid){
                funmenu_number(4);
                return;
            }
            var index2=layer.load(1, {shade: [0.1,'#fff']});
            $.post("{php echo $this->createMobileUrl('index',array('op'=>'getordergoods'))}",{mid:mid},function(returnstr) {
                layer.close(index2);
                console.log(returnstr);
                var result = eval("(" + returnstr + ")");
                if (result.success) {
                    var goods=result.goods;
                    layer.open({
                        type: 1,
                        title:"退菜",
                        area:"400px",
                        skin: 'layui-layer-rim',
                        content:$(".modal_tuigoods").show(),
                        success: function(layero, index){
                            $(".modal_tuigoods form")[0].reset();
                            $("#tgid_mid").val(mid);
                            $("#tgid_num").val(goods.num).attr("max",goods.num);
                            layui.use('form', function() {
                                var form = layui.form;
                                form.render();
                                form.on('submit(tgid_btnsubmit)', function(data){
                                    //获取表单数据
                                    console.log(JSON.stringify(data.field));
                                    var param={
                                        "mid":$("#tgid_mid").val(),
                                        "num":parseInt($("#tgid_num").val()),
                                        "reason":$("#tgid_reason option:selected").val(),
                                        "getback":parseInt(data.field.tgid_getback),
                                        "print":parseInt(data.field.tgid_print),
                                        "remark":parseInt($("#tgid_remark").val()),
                                    };
                                    var index3=layer.load(1, {shade: [0.1,'#fff']});
                                    $.post("{php echo $this->createMobileUrl('index',array('op'=>'refundgoods'))}",param,function(returnstr2) {
                                        layer.close(index3);
                                        console.log(returnstr2);
                                        var result2 = eval("(" + returnstr2 + ")");
                                        if (result2.success) {
                                            layer.closeAll();
                                            var refundid=result2.refundid;
                                            if(param["print"]==1){
                                                fun_print(31,refundid);
                                            }
                                            fun_formatMenu(result2.table,result2.trade,result2.goods);
                                        }else{
                                            layer.msg(result2.msg,{icon:2,time:2000});
                                            return false;
                                        }
                                        return false;
                                    });
                                    return false;
                                });
                            });
                        },
                        end:function(){
                            $(".modal_tuigoods").hide();
                        }
                    });
                }else{
                    layer.msg(result.msg,{icon:2,time:2000});
                    return;
                }
            });
        break;
	}
}
function fun_sumTotal(){
	var total=0;
	var num=0;
	$(".listmenu .priceinput").each(function(index, element) {
        total+=parseFloat($(this).find("span").text().replace("￥",""));
    });
	$(".listmenu .txt_num").each(function(index, element) {
        num+=parseInt($(this).text());
    });
	$("#txt_total").text(total.toFixed(2));
	$(".temp_1 .til span").text($(".listmenu .priceinput").size());
	$(".temp_1 .num span").text(num);
	
}

function fun_selectgood(gid){
	if(!$("#orderid").val()){
		layer.msg("请先开台",{icon:2,time:2000});
		return;
	}
	if($(".goodlist li[gid='"+gid+"'] .mstore").size()){
		var remain=parseInt($(".goodlist li[gid='"+gid+"'] .mstore").text().replace("剩：",""));
		if(remain==0){
			layer.msg("库存不足",{icon:2,time:2000});
			return;
		}
	}
    var taste=arguments.length>1 ? arguments[1] : "";
    if($(".goodlist li[gid='"+gid+"']").attr("taste") && arguments.length==1){
        fun_selectTaste(gid);
        return;
    }
	var oTarget=$(".goodlist li[gid='"+gid+"']");
	var index=$(".listmenu li").size()+1;
    var ispackage=parseInt(oTarget.attr("ispackage"));
	var price=oTarget.attr("price");
	var mprice=oTarget.attr("mprice");
	var title=oTarget.attr("title");
	var goodsn=oTarget.attr("goodsn");
    if(ispackage==1){
        var index2=layer.load(1, {shade: [0.1,'#fff']});
        $.post("{php echo $this->createMobileUrl('index',array('op'=>'getgoodpackage'))}",{id:gid},function(returnstr) {
            layer.close(index2);
            console.log(returnstr);
            var result = eval("(" + returnstr + ")");
            if (result.success) {
                var list = result.list;
                if (list.length == 0)return;
                for(var i in list){
                    menuListSwiper.prependSlide('<li class="swiper-slide" ispackage="1" isnew="true" gid="'+list[i].id+'" goodsn="" title="[套餐]'+list[i].title+'" price="'+list[i].price+'" mprice="" oprice="'+list[i].price+'" onclick="fun_selectmenu(this)"><div class="til">[套]'+list[i].title+'<div class="taste"></div><div class="extension"></div></div><div class="numinput"> <span class="txt_num">1</span> </div><div class="priceinput"> <span>￥'+list[i].price+'</span> <s></s></div></li>');
                }
                $(".listmenu").css("overflow","visible");
                menuListSwiper.updateSlidesSize();
                menuListSwiper.slideTo(0);
                fun_sumTotal();
            }
        });
        return;
    }
	menuListSwiper.prependSlide('<li class="swiper-slide" isnew="true" gid="'+gid+'" goodsn="'+goodsn+'" title="'+title+'" price="'+price+'" mprice="'+mprice+'" oprice="'+price+'" onclick="fun_selectmenu(this)"><div class="til">'+title+'<div class="taste">'+taste+'</div><div class="extension"></div></div><div class="numinput"> <span class="txt_num">1</span> </div><div class="priceinput"> <span>￥'+price+'</span> <s></s></div></li>');
	$(".listmenu").css("overflow","visible");
	menuListSwiper.updateSlidesSize();
	menuListSwiper.slideTo(0);
	//---修改显示库存---//
	if($(".goodlist li[gid='"+gid+"'] .mstore").size()){
		var remain=parseInt(oTarget.find(".mstore").text().replace("剩：",""));
		oTarget.find(".mstore").text("剩："+(remain-1));
	}
	fun_sumTotal();
	
}
function fun_selectTaste(gid){
    layer.open({
        type: 1,
        title:"选择口味",
        area:'440px',
        skin: 'layui-layer-rim',
        content:$(".modal_taste").show(),
        btn:['确认','取消'],
        btn1:function(index,layero){
            var temp=[];
            $(".modal_taste .isselect").each(function(index, element) {
                temp.push($(this).text());
            });
            fun_selectgood(gid,temp.join(','));
            layer.close(index);
        },
        success: function(layero, index){
            var tastestr=$(".goodlist li[gid='"+gid+"']").attr("taste");
            var tasteary=tastestr.split("|");
            $(".modal_tastebox").empty();
            for(var i in tasteary){
                $(".modal_tastebox").append("<span>"+tasteary[i]+"</span>");
            }
            $(".modal_tastebox span").bind("click",function(){
                if($(this).hasClass("isselect")){
                    $(this).removeClass("isselect");
                }else{
                    $(this).addClass("isselect");
                }
            });
        },
        end:function(){
            $(".modal_taste").hide();
            $(".modal_tastebox span").unbind("click");
        }
    });
}
function fun_selectgoodpcate(pcate){
	$(".right_topmenu .swiper-slide[gcid='"+pcate+"']").addClass("isselect").siblings().removeClass("isselect");
	var index2=layer.load(1, {shade: [0.1,'#fff']});
	$.post("{php echo $this->createMobileUrl('index',array('op'=>'getpcategood'))}",{pcate:pcate},function(returnstr){
		layer.close(index2);
		console.log(returnstr);
		var result=eval("("+returnstr+")");
		if(result.success){
			goodsListSwiper.removeAllSlides();
			var list=result.list;
			if(list.length==0)return;
			var tempAry=[];
			var key=0;
			
			/*面积计算*/
			var height=$(".right_goodslist .swiper-container").height();
            var width=$(".right_goodslist .swiper-container").width();
			var temp_size=parseInt(height/165)*parseInt(width/170);
			var psize=temp_size;
			for(var i in list){
				if(key==psize){
					goodsListSwiper.appendSlide('<div class="swiper-slide"><ul class="goodlist">'+tempAry.join(" ")+'</ul></div>');
					key=0;
					tempAry=[];
				}
                if(pcate==-2){
                    var temp='<li ispackage="1" gid="'+list[i].id+'" title="'+list[i].title+'" goodsn="" store="-1" price="'+list[i].price+'" mprice="'+list[i].memberprice+'" taste=""> <A href="javascript:" onclick="fun_selectgood('+list[i].id+')"><div class="img"><img src="'+list[i].thumb+'" onerror="this.src=\'{MODULE_URL}template/resources/img/002.png\';" style="width:80px; height:80px;"></div><div class="info"><h3>';
                    temp+=list[i].title+'</h3><p>套餐</p><p><span>￥'+list[i].price+'/份</span> ';
                    temp+='</p></div></A></li>';
                    tempAry.push(temp);
                    key++;
                }else {
                    var temp = '<li gid="' + list[i].id + '" title="' + list[i].title + '" goodsn="' + list[i].goodsn + '" store="' + list[i].store + '" price="' + list[i].marketprice + '" mprice="' + list[i].memberprice + '"  taste="' + list[i].taste + '"> <A href="javascript:" onclick="fun_selectgood(' + list[i].id + ')"><div class="img"><img src="' + list[i].thumb + '" onerror="this.src=\'{MODULE_URL}template/resources/img/002.png\';" style="width:100%; height:100px;"></div><div class="info"><h3>';
                    var title = list[i].title;
                    if (title.indexOf("]") > -1)title = title.replace("[", "<b style='color:#F60'>[").replace("]", "]</b>");
                    temp += title + '</h3><p><span>￥' + list[i].marketprice + '/' + list[i].unitname + '</span> ';
                    if (parseInt(list[i].store) > -1)temp += '<span class="pull-right mstore">剩：' + list[i].store + '</span>';
                    temp += '</p></div></A></li>';
                    tempAry.push(temp);
                    key++;
                }
			}
			if(tempAry.length>0){
				goodsListSwiper.appendSlide('<div class="swiper-slide"><ul class="goodlist">'+tempAry.join(" ")+'</ul></div>');
			}
		}else{
			layer.msg(result.msg,{icon:2,time:2000});
			return;
		}
		
	});
}

function fun_selectTablePcate(pcate){
	if(pcate==0){
		$(".pt_menuitem").eq(0).addClass("isselect").siblings().removeClass("isselect");
	}else{
		$(".pt_menuitem[tpcate='"+pcate+"']").addClass("isselect").siblings().removeClass("isselect");
	}
	$(".page_table").height($(".page_left").height()).show();
	if(tablePcateswiper==null || tablePcateswiper==="undefined"){
		tablePcateswiper = new Swiper('.pt_menubar', {
			nextButton: '.pt_pagebtn_l',
			prevButton: '.pt_pagebtn_r',
			slidesPerView: 6,
			spaceBetween:1
		});
	}
	var index2=layer.load(1, {shade: [0.1,'#fff']});
	$.post("{php echo $this->createMobileUrl('index',array('op'=>'getpcatetable'))}",{pcate:pcate},function(returnstr){
		layer.close(index2);
		console.log(returnstr);
		var result=eval("("+returnstr+")");
		if(result.success){
			$("#txt_ptstatus_0").text(result.num0);
			$("#txt_ptstatus_1").text(result.num1);
			$("#txt_ptstatus_2").text(result.num2);
			$("#txt_ptstatus_all").text(result.allnum)
			if(tableSwiper==null || tableSwiper==="undefined")tableSwiper=new Swiper('.pt_tablelist');
			tableSwiper.removeAllSlides();
			var list=result.list;
			if(list.length==0)return;
			var tempAry=[];
			var key=0;
			var psize=10;
			var _width=$(".page_table_list").width();
			var _height=$(".page_table").height()-180;
			var _w1=parseInt(_width*0.2)>150 ? 150 : parseInt(_width*0.2);
			psize=parseInt(_width/_w1)*parseInt(_height/160);

			for(var i in list){
				if(key==psize){
					tableSwiper.appendSlide('<div class="swiper-slide"><ul>'+tempAry.join(" ")+'</ul></div>');
					key=0;
					tempAry=[];
				}
                var tempcolor="";
                var tempstr="";
                if(parseInt(list[i].pauseorder)==1){
                    tempcolor=' style="background:#01AAED;" ';
                    tempstr='<span style="float:right">暂缓</span>'
                }
				var temp='<li class="status_'+list[i].status+'" tid="'+list[i].id+'" status="'+list[i].status+'" ispay="'+list[i].ispay+'" pauseorder="'+list[i].pauseorder+'" onclick="fun_selectTable('+list[i].id+')"><a href="javascript:" '+tempcolor+'><div class="pt_maxnum">'+tempstr+''+list[i].maxnum+'人桌</div><h2>'+list[i].title+'</h2><div class="pt_time text-center">';
				switch(parseInt(list[i].status)){
					case 0:
						temp+='空闲';
					break;
					case 1:
						temp+='已开台';
					break;
					case 2:
						temp+='已点菜';
					break;
					case 3:
						temp+='预定';
					break;
				}
				if(parseInt(list[i].ispay))temp+=' <span>已付款</span>';
                if(parseInt(list[i].newctrl))temp+=' <span style="color:#FEEC24">待处理</span>';
				if(parseInt(list[i].ismore))temp+=' <span>拼桌</span>';
                temp+='</div><div class="text-center">';
                temp+= parseInt(list[i].status)>0 ? fromatTime(list[i].createtime,'m/d h:i') : "&nbsp;";
                temp+='</div></a></li>';
				tempAry.push(temp);
				key++;
			}
			if(tempAry.length>0){
				tableSwiper.appendSlide('<div class="swiper-slide"><ul>'+tempAry.join(" ")+'</ul></div>');
			}
		}else{
			layer.msg(result.msg,{icon:2,time:2000});
			return;
		}
	});
}

function fun_selectTable(num){
	if(!num)return;
	var target=$(".pt_tablelist li[tid='"+num+"']");
	var status=parseInt(target.attr("status"));
	var ispay=parseInt(target.attr("ispay"));
    var pauseorder=parseInt(target.attr("pauseorder"));
	target.addClass("isselect").siblings().removeClass("isselect");
	if(status==0){
		fun_modal({title:"开桌-就餐人数",type:false,val:0,success:function(obj,index){
			if(parseInt(obj)<=0 || isNaN(obj)){
				layer.msg("请输入正确的就餐人数",{icon:2,time:2000});
				return;
			}
			layer.close(index);
			var index2=layer.load(1, {shade: [0.1,'#fff']});
			$.post("{php echo $this->createMobileUrl('index',array('op'=>'postneworder'))}",{tid:num,num:obj},function(returnstr){
				layer.close(index2);
				var result=eval("("+returnstr+")");
				if(result.success){
					$(".page_table").hide();
					fun_formatMenu(result.table,result.trade);
				}else{
					layer.msg(returnstr,{icon:2,time:2000});
					return;
				}
				
			});
		}});
	}else if(status==1){
		layer.open({
			type: 1,
			title:"操作",
			area:'440px',
            shadeClose:true,
			skin: 'layui-layer-rim',
			content:$(".modal_selectMovement").show(),
			success: function(layero, index){
				$(".modal_selectMovement").attr("index",index);
				$("#tablestatus0").show();
				$("#tablestatus1").hide();
				$("#tablestatus2").hide();
				var index2=layer.load(1, {shade: [0.1,'#fff']});
				$.post("{php echo $this->createMobileUrl('index',array('op'=>'postneworder'))}",{tid:num},function(returnstr){
					layer.close(index2);
					var result=eval("("+returnstr+")");
					if(result.success){
						fun_formatMenu(result.table,result.trade);
					}else{
						layer.msg(returnstr,{icon:2,time:2000});
						return;
					}
					
				});
			},
			end:function(){
				$(".modal_selectMovement").hide();
			}
		});
	}else if(status==2){
		$.post("{php echo $this->createMobileUrl('index',array('op'=>'postneworder'))}",{tid:num},function(returnstr){
			var result=eval("("+returnstr+")");
			console.log(returnstr);
			if(result.success){
				layer.open({
					type: 1,
					title:"操作",
					area:'440px',
                    shadeClose:true,
					skin: 'layui-layer-rim',
					content:$(".modal_selectMovement").show(),
					success: function(layero, index){
						$(".modal_selectMovement").attr("index",index);
						if(ispay){
							$("#tablestatus0").hide();
							$("#tablestatus1").hide();
							$("#tablestatus2").show();
						}else{
							$("#tablestatus0").hide();
							$("#tablestatus1").show();
							$("#tablestatus2").hide();
							fun_formatMenu(result.table,result.trade,result.goods);
						}
                        if(pauseorder==0){
                            $(".pauseorder1").show();
                            $(".pauseorder2").hide();
                        }else if(pauseorder==1){
                            $(".pauseorder2").show();
                            $(".pauseorder1").hide();
                        }else if(pauseorder==2){
                            $(".pauseorder2").hide();
                            $(".pauseorder1").hide();
                        }
					},
					end:function(){
						$(".modal_selectMovement").hide();
					}
				});
			}else{
				layer.msg(returnstr,{icon:2,time:2000});
				return;
			}
			
		});
	}
}
function fun_selectOrder(id){
	$.post("{php echo $this->createMobileUrl('index',array('op'=>'getorderdetail2'))}",{orderid:id},function(returnstr){
		var result=eval("("+returnstr+")");
		if(result.success){
			layer.closeAll();
			layer.open({
				type: 1,
				title:"操作",
				area:'440px',
				skin: 'layui-layer-rim',
				content:$(".modal_selectMovement").show(),
				success: function(layero, index){
					$(".modal_selectMovement").attr("index",index);
					$("#tablestatus0").hide();
					$("#tablestatus1").show();
					fun_formatMenu(result.table,result.trade,result.goods);
				},
				end:function(){
					$(".modal_selectMovement").hide();
				}
			});
		}else{
			layer.msg(returnstr,{icon:2,time:2000});
			return;
		}
	});
}
function fun_munebtn_dc(){
	var tid=parseInt($("#pt_tablelist  .isselect").attr("tid"));
	if(!tid){
		layer.msg("请先选择餐台",{icon:2,time:2000});
		return;
	}
	var index2=layer.load(1, {shade: [0.1,'#fff']});
	$.post("{php echo $this->createMobileUrl('index',array('op'=>'postneworder'))}",{tid:tid},function(returnstr){
		layer.close(index2);
		var result=eval("("+returnstr+")");
		if(result.success){
			$(".page_table").hide();
			$("#txt_tablename").text(result.table.title);
			$("#orderid").val(result.trade.id);
		}else{
			layer.msg(returnstr,{icon:2,time:2000});
			return;
		}
	});
}
function fun_modal(param){
	layer.open({
		type: 1,
		title:param.title,
		area:'320px',
		skin: 'layui-layer-rim',
        shadeClose:true,
		content:$(".modal_counter").show(),
		success: function(layero, index){
			if(!param.type){
				$("#modal_doc").hide();
			}else{
				$("#modal_doc").show();
			}
			if(param.val){
				$('#moadConterInput').val(param.val);
				$('#moadConterInput').select();
			}else{
				$('#moadConterInput').val('');
			}
			if(param.tips){
				$('#moadConterInput').attr("placeholder",param.tips);
			}else{
				$('#moadConterInput').attr('placeholder','');
			}
			$("#modal_cantrl").on("click",function(){
				layer.close(index);
			});
			$("#modal_sure").on("click",function(){
				if(typeof(param.success)=='function'){param.success($('#moadConterInput').val(),index);}
			});
		},
		end:function(){
			$(".modal_counter").hide();
			param=null;
			$("#modal_cantrl").unbind("click");
			$("#modal_sure").unbind("click");
		}
	});
}
function Counter(num,obj){
	var vTecla=num;
	var salida=$(obj);
	if(vTecla=='C'){
		salida.val('0');
		if(obj=="#ppl_input_paidfee")fun_paycount();
		return false;
	}
	
	if(vTecla=='B'){
		var temp1=salida.val();
		salida.val(temp1.substr(0,temp1.length-1));
		if(obj=="#ppl_input_paidfee")fun_paycount();
		return false;
	}
	if(salida.val().length>8){
		return false;	
	}
	if(vTecla=='.'){
		if(salida.val().indexOf('.')>-1){
			salida.val(salida.val());
		}else{
			salida.val(salida.val()+vTecla);
		}
	}else if(vTecla=='0'){
		if(salida.val()==0 && salida.val().length==1){
			salida.val(0);
		}else{
			salida.val(salida.val()+vTecla);
		}
	}else{
		if((salida.val()==0 && salida.val().length==1)){
			salida.val(vTecla);
		}else{
			salida.val(salida.val()+vTecla);
		} 
	}
	var temp=salida.val();
	if(temp.indexOf('.')>-1){
		var float=temp.split('.');
		if(float[1].length>2){
			salida.val(float[0]+'.'+float[1].substr(0,2));
		}
	}
	if(obj=="#ppl_input_paidfee")fun_paycount();
}

function fun_ctrlorder(type){
	if(!$(".page_table_list .isselect").size()){
		layer.msg("请先选择餐台",{icon:2,time:2000});
		return;
	}
	var target=$(".page_table_list .isselect");
	var tid=target.attr("tid");
	if(type==1){
		var index2=layer.load(1, {shade: [0.1,'#fff']});
		$.post("{php echo $this->createMobileUrl('index',array('op'=>'postneworder'))}",{tid:tid},function(returnstr){
			layer.closeAll();
			$(".page_table").hide();
			console.log(returnstr);
			var result=eval("("+returnstr+")");
			if(result.success){
				fun_formatMenu(result.table,result.trade,result.goods);
			}else{
				layer.msg(result.msg,{icon:2,time:2000});
				return;
			}
			
		});
		return;
		
	}else if(type==2){
		var index2=layer.load(1, {shade: [0.1,'#fff']});
		$.post("{php echo $this->createMobileUrl('index',array('op'=>'cleartable'))}",{tid:tid},function(returnstr){
			layer.closeAll();
			$(".page_table").hide();
			console.log(returnstr);
			var result=eval("("+returnstr+")");
			if(result.success){
				resetFormInput();
				$(".page_table_list li[tid='"+tid+"']").attr({"class":"status_0 isselect","status":0});
				$(".page_table_list li[tid='"+tid+"']").find(".pt_time").text("空闲");
			}else{
				layer.msg(result.msg,{icon:2,time:2000});
				return;
			}
		});
		return;
		
	}else if(type==3){
		//转台
		var orderid=$("#orderid").val();
		var index2=layer.load(1,{shade:[0.1,'#fff']})
		layer.open({
			type:1,
			title:0,
			shade: [0.1,'#fff'],
			area:['760px','480px'],
			skin: 'layui-layer-rim',
			content:$(".modal_selecttable").show(),
			success: function(layero, index){
				$(".modal_selecttableleft li").eq(0).click();
				$(".modal_selecttable").attr("index",index);
			},
			end:function(){
				$(".modal_selecttable").hide();
			}
		});
	}else if(type==4){
		//加菜
		layer.closeAll();
		$("#Txt_search").val('');
		$("#txt_total").text('0.00');
		$("#btn_getback").hide();
		$("#btn_submitorder").show();
		$(".temp_1 .til span").text('');
		$(".temp_1 .num span").text('');
		$('.page_table').hide();
		menuListSwiper.removeAllSlides();
		var index2=layer.load(1, {shade: [0.1,'#fff']});
		$.post("{php echo $this->createMobileUrl('index',array('op'=>'getorderdetail'))}",{tid:tid},function(returnstr){
			layer.close(index2);
			console.log(returnstr);
			var result=eval("("+returnstr+")");
			if(result.success){
				$('.page_table').hide();
				fun_formatMenu(result.table,result.trade,result.goods);
			}else{
				layer.msg(result.msg,{icon:2,time:2000});
				return;
			}
		});
        return;
	}else if(type==6){
		//完成
		var index2=layer.load(1, {shade: [0.1,'#fff']});
		$.post("{php echo $this->createMobileUrl('index',array('op'=>'finishorder'))}",{tid:tid},function(returnstr){
			layer.close(index2);
			console.log(returnstr);
			var result=eval("("+returnstr+")");
			if(result.success){
				layer.msg("操作成功",{icon:1,time:2000});
				layer.closeAll();
				$('.page_table').hide();
				resetFormInput();
			}else{
				layer.msg(result.msg,{icon:2,time:2000});
				return;
			}
		});
		
	}else if(type==7){
		layer.closeAll();
		$("#btnpay").click();
        return;
	}else if(type==8){
		fun_modal({title:"修改就餐人数",type:false,tips:0,success:function(obj,index1){
			if(parseInt(obj)<0 || isNaN(obj)){
				layer.msg("请输入正确的就餐人数",{icon:2,time:2000});
				return;
			}
			var orderid=$("#orderid").val();
			layer.closeAll();
            setTimeout(function(){
                var index2=layer.load(1, {shade: [0.1,'#fff'],shadeClose: true});
                $.post("{php echo $this->createMobileUrl('index',array('op'=>'changeorder'))}",{orderid:orderid,person:obj},function(returnstr){
                    layer.close(index2);
                    var result=eval("("+returnstr+")");
                    if(result.success){
                        var tid=$(".page_table_list .isselect").attr("tid");
                        fun_selectTable(tid);
                    }else{
                        layer.msg(returnstr,{icon:2,time:2000});
                        return;
                    }
                });
            },300)
		}});
		
	}else if(type==9){
		var orderid=$("#orderid").val();
        if(orderid){
            var index2=layer.load(1, {shade: [0.1,'#fff']});
            $.post("{php echo $this->createMobileUrl('index',array('op'=>'chcecknewprint'))}",{orderid:orderid},function(returnstr) {
                layer.close(index2);
                console.log(returnstr);
                var result = eval("(" + returnstr + ")");
                if (result.success) {
                    fun_print(2,orderid,"new");
                    fun_print(3,orderid,"new");
                } else {
                    layer.msg("无新增菜品",{icon:2,time:2000});
                    return;
                }
            });
        }
    }else if(type==10){
        layer.closeAll();
        return;
    }else if(type==11){
        //叫起
        var index2=layer.load(1, {shade: [0.1,'#fff']});
        $.post("{php echo $this->createMobileUrl('index',array('op'=>'holdonorder'))}",{holdtype:1,tid:tid},function(returnstr) {
            layer.closeAll();
            console.log(returnstr);
            var result=eval("("+returnstr+")");
            if(result.success){
                fun_selectTablePcate(0);
                var orderid=result.orderid;
                if(orderid){
                    fun_print(3,orderid);
                }
            }else{
                layer.msg(result.msg,{icon:2,time:2000});
                return;
            }
        });
    }else if(type==12){
        var index2=layer.load(1, {shade: [0.1,'#fff']});
        $.post("{php echo $this->createMobileUrl('index',array('op'=>'holdonorder'))}",{holdtype:2,tid:tid},function(returnstr) {
            layer.closeAll();
            console.log(returnstr);
            var result=eval("("+returnstr+")");
            if(result.success){
                fun_selectTablePcate(0);
                var orderid=result.orderid;
                if(orderid){
                    fun_print(3,orderid);
                }
            }else{
                layer.msg(result.msg,{icon:2,time:2000});
                return;
            }
        });
    }
}
function fun_selectTablePcate2(pcate){
	$(".modal_selecttableleft li[tpcate='"+pcate+"']").addClass("isselect").siblings().removeClass("isselect");
	var index2=layer.load(1, {shade: [0.1,'#fff']});
	$.post("{php echo $this->createMobileUrl('index',array('op'=>'getpcatetable'))}",{pcate:pcate},function(returnstr){
		layer.close(index2);
		console.log(returnstr);
		var result=eval("("+returnstr+")");
		if(result.success){
			$(".modal_selecttableright ul").empty();
			var list=result.list;
			if(list.length==0){
				$(".modal_selecttableright ul").text("暂无内容");
				return;
			}
			for(var i in list){
                if(parseInt(list[i].status))continue;
				if(list[i].id==$(".page_table_list .isselect").attr('tid'))continue;
				var temp='<li class="status_'+list[i].status+'"  tid="'+list[i].id+'" status="'+list[i].status+'" onclick="fun_selectTable2('+list[i].id+')"><div>'+list[i].maxnum+'人桌</div><h2>'+list[i].title+'</h2><div class="text-center">';
				switch(parseInt(list[i].status)){
					case 0:
						temp+='闲';
					break;
					case 1:
						temp+='开';
					break;
					case 2:
						temp+='点';
					break;
					case 3:
						temp+='预';
					break;
				}
				temp+='</div><div class="pt_label">';
				if(parseInt(list[i].ispay))temp+='<span>付</span>';
				if(parseInt(list[i].ismore))temp+='<span>拼</span>';
				temp+='</div></li>';
				$(".modal_selecttableright ul").append(temp);
			}
		}else{
			layer.msg(result.msg,{icon:2,time:2000});
			return;
		}
		
	});
}
function fun_selectTable2(tid){
	var otid=$(".page_table_list .isselect").attr("tid");
	layer.confirm('确认要转到该台？', {
		btn: ['确认','取消']
	}, function(){
		var index2=layer.load(1, {shade: [0.1,'#fff']});
		$.post("{php echo $this->createMobileUrl('index',array('op'=>'truntable'))}",{otid:otid,tid:tid},function(returnstr){
			layer.close(index2);
			console.log(returnstr);
			var result=eval("("+returnstr+")");
			if(result.success){
				layer.msg("操作成功",{icon:1,time:2000},function(){
					layer.closeAll();
					$('.page_table').hide();
					resetFormInput();
				});
			}else{
				layer.msg(result.msg,{icon:2,time:2000});
				return;
			}
		})
	});
}
function fun_munebtn_clear(){
	layer.confirm('清空当前订单？<br>清空并不会删除该订单', {}, function(){
		layer.closeAll();
		resetFormInput();
	});
}
function fun_munebtn_submitorder(){
	if(!$(".listmenu li").size()){
		layer.msg("请先添加商品",{icon:2,time:2000});
		return;
	}
	var orderid=$("#orderid").val();
	var param=[];
	$(".listmenu li").each(function(index, element) {
        var id=$(this).attr("mid")!="undefined" ? $(this).attr("mid") : "";
		var goodid=$(this).attr("gid");
		var price=$(this).attr("price");
		var mprice=$(this).attr("mprice");
		var oprice=$(this).attr("oprice");
		var title=$(this).attr("title");
		var goodsn=$(this).attr("goodsn");
		var num=$(this).find(".txt_num").text();
		var fee=$(this).find(".priceinput").find("span").text().replace("￥","");
		var taste=$(this).find(".taste").text();
		var ispack=$(this).find(".ispack").size();
		var temp=id+"|"+goodid+"|"+goodsn+"|"+title+"|"+price+"|"+mprice+"|"+oprice+"|"+num+"|"+fee+"|"+ispack+"|"+taste;
		param.push(temp);
    });
	var index2=layer.load(1, {shade: [0.1,'#fff']});
	$.post("{php echo $this->createMobileUrl('index',array('op'=>'submitorder'))}",{param:param,orderid:orderid},function(returnstr){
		layer.close(index2);
		console.log(returnstr);
		var result=eval("("+returnstr+")");
		if(result.success){
			layer.open({
				type: 1,
				title:"操作",
				area:'440px',
				skin: 'layui-layer-rim',
				content:$(".modal_AfterSumit").show(),
				success: function(layero, index){
					$(".modal_AfterSumit").attr("index",index);
					$(".modal_AfterSumit").attr("orderid",orderid);
                    if(result.isnewgood){
                        $("#isnewgood1").hide();
                        $("#isnewgood2").show();
                        $(".pauseorder3").hide();
                    }else{
                        $("#isnewgood1").show();
                        $("#isnewgood2").hide();
                        $(".pauseorder3").show();
                        fun_print(2,orderid);
                    }
					resetFormInput();
				},
				end:function(){
					$(".modal_AfterSumit").hide();
				}
			});
		}else{
			layer.msg(result.msg,{icon:2,time:2000});
			return;
		}
		
	});
}
function resetFormInput(){
	$("#Txt_search").val('');
	$("#txt_tablename").text('');
	$("#orderid").val('');
	$("#txt_total").text('0.00');
	$("#form_menu")[0].reset();
	$("#btn_getback").show();
	$("#btn_submitorder").hide();
	$(".temp_1 .til span").text('');
	$(".temp_1 .num span").text('');
	$("#txt_person").text('');
	$("#txt_teafee").text('');
	menuListSwiper.removeAllSlides();
}
function fun_formatMenu(table,trade){
	resetFormInput();
    $("#txt_tablename").text(table.title);
	$("#orderid").val(trade.id);
	$("#txt_person").text(trade.person);
	$("#txt_teafee").text(fee2num(trade.teafee));
	if(trade.ispay==0){
		$("#btn_getback").hide();
		$("#btn_submitorder").show();
		
	}else if(trade.ispay==1){
		$("#btn_getback").hide();
		$("#btn_submitorder").hide();
	}
	if(arguments.length<3)return;
	var goods=arguments[2];
	for(var i in goods){
		var temp='<li class="swiper-slide" isnew="false" mid="'+goods[i].id+'" title="'+goods[i].title+'" goodsn="'+goods[i].goodsn+'" gid="'+goods[i].goodid+'" price="'+goods[i].price+'" mprice="'+goods[i].memberprice+'" oprice="'+goods[i].oldprice+'" isprint="'+goods[i].isprint+'" onclick="fun_selectmenu(this)"><div class="til">'+goods[i].title+'<div class="taste">'+goods[i].taste+'</div>';
        temp+='<div class="extension">';
        if(parseInt(goods[i].ispack))temp+='<span class="red">打包</span>';
        if(parseInt(goods[i].ispay))temp+='<span class="green">已付</span>';
        temp+='</div></div><div class="numinput"> <span class="txt_num">'+goods[i].num+'</span> </div><div class="priceinput"> ';
        var total=parseInt(str2num(goods[i].price))*parseInt(goods[i].num);
        if(total==parseInt(goods[i].total_fee)){
            temp+='<span>￥'+fee2num(total)+'</span> <s></s></div>';
        }else{
            temp+='<span>￥'+fee2num(goods[i].total_fee)+'</span> <s>￥'+fee2num(total)+'</s></div>';
        }
        temp+='</li>';
        menuListSwiper.prependSlide(temp);
	}
	$(".listmenu").css("overflow","visible");
	menuListSwiper.updateSlidesSize();
	menuListSwiper.slideTo(0);
	fun_sumTotal();
}

function funExtend_btn(obj){
	var url=$(obj).attr("url");
	var title=$(obj).text();
	var _height=$(window).height();
	var _width=$(window).width();
	layer.open({
	  type: 2,
	  title:title,
	  shadeClose: true,
	  shade: 0.8,
	  area: [_width+'px', _height+'px'],
	  content: url
	}); 
}

function fun_ctrlAftersumit(type){
	var index=$(".modal_AfterSumit").attr("index");
	var orderid=$(".modal_AfterSumit").attr("orderid");
	switch(type){
		case 1:
			layer.close(index);
			fun_print(3,orderid,"all");
		break;
		case 2:
			layer.close(index);
			fun_startPay(orderid);
		break;
		case 3:
            layer.close(index);
            var index2=layer.load(1, {shade: [0.1,'#fff']});
            $.post("{php echo $this->createMobileUrl('index',array('op'=>'chcecknewprint'))}",{orderid:orderid},function(returnstr) {
                layer.close(index2);
                console.log(returnstr);
                var result = eval("(" + returnstr + ")");
                if (result.success) {
                    fun_print(3,orderid,"new");
                } else {
                    layer.msg("无新增菜品",{icon:2,time:2000});
                    return;
                }
            });
            break;
        case 4:
            var index2=layer.load(1, {shade: [0.1,'#fff']});
            $.post("{php echo $this->createMobileUrl('index',array('op'=>'holdonorder'))}",{holdtype:1,orderid:orderid},function(returnstr) {
                layer.closeAll();
                console.log(returnstr);
                var result=eval("("+returnstr+")");
                if(result.success){
                    fun_selectTablePcate(0);
                    var orderid=result.orderid;
                    if(orderid){
                        fun_print(3,orderid,"new");
                    }
                }else{
                    layer.msg(result.msg,{icon:2,time:2000});
                    return;
                }
            });
		break;
	}
}

//-------//
function fee2num(num){
    if(num=="")return 0;
    if(isNaN(parseFloat(num)))return 0;
	if(num.toString().indexOf(".")>-1)return num;
	var fee=(parseInt(num)*0.01).toFixed(2);
	return fee;
}
function fromatTime(time){
	var datetime = new Date();
	datetime.setTime(time*1000);
	var year = datetime.getFullYear();
	var month = datetime.getMonth() + 1;
	var date = datetime.getDate();
	var hour = datetime.getHours();
	var minute = datetime.getMinutes();
	var second = datetime.getSeconds();
	var mseconds = datetime.getMilliseconds();
	if(hour<10)hour="0"+hour;
	if(month<10)month="0"+month;
	if(minute<10)minute="0"+minute;
	
	var timetype="m/d h:i";
	if(arguments[1])timetype=arguments[1];
	timetype=timetype.replace("y",year);
	timetype=timetype.replace("m",month);
	timetype=timetype.replace("d",date);
	timetype=timetype.replace("h",hour);
	timetype=timetype.replace("i",minute);
	timetype=timetype.replace("s",second);
	return timetype;
}
function fun_print(ptype,orderid){
	var iskey=arguments.length>2 ? arguments[2] : '';
	layer.load(1,{shade: [0.1,'#fff'],time:1500});
	$("#print_iframe").removeAttr("src").attr("src","{$_W['siteroot']}app/index.php?i={$_W['uniacid']}&c=entry&ptype="+ptype+"&m=j_hmoney&do=print&orderid="+orderid+"&iskey="+iskey+"&userid={php echo $userid}");
}
//window.onbeforeunload = function(e){
//	return e.returnValue='';
//};
</script>